namespace EyeOpen.Web.Hosting
{
	using System;
	using System.Collections.Generic;

	public abstract class VirtualPathInitializer
	{
		private readonly IDictionary<string, Tuple<string, string>> virtualPathDictionary =
			new Dictionary<string, Tuple<string, string>>();

		public IDictionary<string, Tuple<string, string>> Initialize()
		{
			RegisterViewList();

			return
				virtualPathDictionary;
		}

		protected abstract void RegisterViewList();

		protected virtual void RegisterView(string viewPath, string assembly)
		{
			var key = string.Format("/Views/{0}.cshtml", viewPath);

			var partialResourcePath = viewPath.Replace("/", ".");

			var assemblyFullName = GetFullName(assembly);

			var resourcePath = string.Format("{0}.Views.{1}.cshtml", assembly, partialResourcePath);

			virtualPathDictionary.Add(key, new Tuple<string, string>(assemblyFullName, resourcePath));
		}

		protected virtual string GetFullName(string assembly)
		{
			return assembly;
		}
	}
}